package com.nuanshui.framework.res.qiniu;

import com.nuanshui.heatedloan.enums.FileBelong;
import com.nuanshui.heatedloan.model.Image;
import org.springframework.beans.BeanUtils;

/**
 * Created by zxh on 2017/7/2.
 */
public class UpLoadFileResult {

    private UpLoadFileVO file;

    private Image image;

    public UpLoadFileVO getFile() {
        return file;
    }

    public void setFile(UpLoadFileVO file) {
        this.file = file;
    }

    public Image getImage() {
        if (image == null) {
            image = convertUpLoadFileToImage(file);
        }
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public static Image convertUpLoadFileToImage(UpLoadFileVO item)
    {
        Image image = new Image();
        BeanUtils.copyProperties(item, image);
        image.setId(null);
        image.setBelong(FileBelong.PRODUCT);
        image.setImgUrl(item.getUrl());
        return image;
    }
}
